home *** CD-ROM | disk | FTP | other *** search
- // Tools Plus Tutorial -- Pop-Up Menus
-
-
-
-
- #include "ToolsPlus.h"
-
-
- #define ordinaryPopUp 1 // Pop-up menu constants for more readable code…
- #define popDownMenu 2
- #define littlePopUp 3
-
- #define DoneButton 255
-
-
-
- TPPollRecord Poll; // Polling record to retrieve event information
- Boolean ExitTheDemo; // Should the demo terminate?
-
- short theButton; // Button number clicked in an alert
-
-
-
- void ApplicationInitialization (void);
-
-
-
-
-
-
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- void main(void)
- {
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- MaxApplZone();
-
-
- if (!InitToolsPlus(1, 1, UseColor))
- ExitToShell();
-
- ApplicationInitialization();
-
- while (!ExitTheDemo) //Main Event Loop
- {
- if (PollSystem(&Poll)) //If an event is available, process the event…
- {
- switch (Poll.What)
- {
-
- case doButton: // User clicked a button ("Done" is the only button we have)…
- ExitTheDemo = true;
- break;
-
- case doPopUpMenu:
- switch (Poll.Menu.Num)
- {
- case ordinaryPopUp:
- // Put check mark (√) beside selected item. Previously selected
- // item is automatically deselected (this feature is optional).
- CheckPopUp(Poll.Menu.Num, Poll.Menu.Item, on);
- break;
-
- case popDownMenu:
- // Your app would likely execute a process here…
- theButton = AlertBox(noteIcon, "\pYour application would do something now.", -OkAlert);
- break;
-
- case littlePopUp:
- // Put bullet (•) beside selected item. Previously selected
- // item is automatically deselected (this feature is optional).
- PopUpMark(Poll.Menu.Num, Poll.Menu.Item, DotChar);
- break;
- }
- break;
-
- default:
- break; //All other events are ignored
- }
- }
- }
- }
-
-
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- void ApplicationInitialization (void)
- {
- // Do all the application setup before you start polling for events…
-
- #define DemoWindow1 1
-
- WindowOpen(DemoWindow1, 0, 0, 225, 170, "\p", dBoxProc + wCenter, NoGoAway, Modal);
-
-
- // Create a Pop-Up Menu that hides the "down arrow". The pop-up menu is populated
- // with icons. Note that the Menu Manager adds 256 to the icon specifier (the
- // number following the "^" mark). Example: ^44 + 256 = 300, or 'cicn' resource
- // ID 300 is used.
- NewPopUp(ordinaryPopUp, 100, 20, 206, 20, "\pSearch Here:", popupIconTitle + popupNoArrow, enabled);
- PopUpMenu(ordinaryPopUp, 1, enabled, "\pDesktop^44");
- PopUpMenu(ordinaryPopUp, 2, enabled, "\pHard Disk^45");
- PopUpMenu(ordinaryPopUp, 3, enabled, "\pTools Plus^46");
- PopUpMenu(ordinaryPopUp, 4, enabled, "\pTHINK C^47");
- PopUpMenu(ordinaryPopUp, 5, enabled, "\pLibraries^47");
- PopUpMenu(ordinaryPopUp, 6, enabled, "\p#Includes^47");
- CheckPopUp(ordinaryPopUp, 1, on); // Select first item by placing a check mark beside it
-
-
- // Create a "pull-down" menu with a fixed title inside the control…
- NewPopUp(popDownMenu, 100, 50, 206, 50, "\pFormat", popupFixedTitle, enabled);
- PopUpMenu(popDownMenu, 1, enabled, "\pClear");
- PopUpMenu(popDownMenu, 2, enabled, "\pParagraph…");
- PopUpMenu(popDownMenu, 3, enabled, "\pCharacter…");
- PopUpMenu(popDownMenu, 4, enabled, "\pStyle…");
-
-
- // Create a pop-up menu using Geneva 9pt…
- TextFont(geneva);
- TextSize(9);
- NewPopUp(littlePopUp, 100, 80, 133, 80, "\pSize:", popupUseWFont + popupNoArrow, enabled);
- PopUpMenu(littlePopUp, 1, enabled, "\p9");
- PopUpMenu(littlePopUp, 2, enabled, "\p10");
- PopUpMenu(littlePopUp, 3, enabled, "\p12!•"); // This item is selected by being marked with a bulled (•)
- PopUpMenu(littlePopUp, 4, enabled, "\p14");
- PopUpMenu(littlePopUp, 5, enabled, "\p18");
- PopUpMenu(littlePopUp, 6, enabled, "\p24");
- PopUpMenu(littlePopUp, 7, enabled, "\p36");
-
-
- NewButton(DoneButton, 85, 130, 140, 150, "\pDone", pushButProc + DefaultButton, enabled, notSelected);
- ExitTheDemo = false;
- }